﻿using System;
using System.Data.SqlClient;
using Devv.Core.UniDataTier;

namespace Yglu.BusinessLayer.Entities
{
	public class Terminal : BaseEntity
	{
		#region Properties

		public String UniqueId { get; set; }

		public Store Store { get; set; }

		#endregion

		#region Extra properties

		public String StoreTitle
		{
			get
			{
				return Store.Title;
			}
		}

		#endregion

		#region Constructor

		public Terminal()
		{
			Store = new Store();
		}

		public Terminal(Int32 id)
		{
			Construct(DataAccess.Terminal_Get(id));
		}

		public Terminal(String uniqueId)
		{
			Construct(DataAccess.Terminal_Get(uniqueId));
		}

		#endregion

		#region Methods

		public override void Load(SqlDataReader reader)
		{
			Id = DataHandler.GetInt32(reader, "TerminalId");
			UniqueId = DataHandler.GetString(reader, "TerminalUniqueId");
			Active = DataHandler.GetBoolean(reader, "TerminalActive");

			Store = new Store();
			Store.Load(reader);
		}

		#endregion

		#region ToString

		public new String ToString()
		{
			return UniqueId;
		}

		#endregion
	}
}